package com.ff.discounts.baseviewlogic

import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import com.ff.discounts.activity.BaseLogicActivity
import com.ff.discounts.entity.response.BaseResponse
import com.ff.discounts.library.log.HiLog
import com.ff.discounts.model.BaseViewModel

/**
 *
 * @author: fufang
 * @date: 2023/10/24
 */
open class BaseViewLogic : AppCompatActivity() {
    protected val hostActivity: BaseViewLogic
        protected  get() = this
    /**
     * 初始化通用ViewModel 逻辑
     */
    fun initViewModel(viewModel: BaseViewModel){
        // 关闭界面
        viewModel.finishPage.observe(this){

        }

        //网络响应业务失败
        viewModel.response.observe(this) {
            onResponse(it)
        }
    }

    open fun onResponse(data: BaseResponse) {
        HiLog.d(data)
//        when (data.status) {
//            401 -> {
//                R.string.error_not_auth.longToast()
//                AppContext.instance.logout()
//            }
//
//            403 -> {
//                R.string.error_not_permission.longToast()
//            }
//
//            404 -> {
//                R.string.error_not_found.longToast()
//            }
//        }
//        (data.message ?: getString(R.string.error_unknown)).longToast()
//        onError()
    }


}